-
-
Notifications
You must be signed in to change notification settings - Fork 369
feat(realtime): add presence enabled flag on join payload #1229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(realtime): add presence enabled flag on join payload #1229
Conversation
- Add enabled field to RealtimeChannelPresenceConfig type - Add _has_callback_attached property to AsyncRealtimePresence - Set presence.enabled based on callback attachment or manual config - Add automatic resubscription when presence callbacks are added to joined channel - Add comprehensive tests for new functionality 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
- Fix AttributeError by mocking _ws_connection instead of trying to set is_connected property - Ensure test properly mocks socket connection for presence enabled flag validation 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
logger.info( | ||
f"channel {self.topic} resubscribe due to change in presence callbacks on joined channel" | ||
) | ||
asyncio.create_task(self._resubscribe()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@o-santi not sure if this create_task
is appropriate here, should I hold a reference for the task to make sure it is finished/cancelled?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, we can hold a reference but there's no real way to make sure its finished without randomly throwing errors, as we cannot raise something out of thin air.
If we really want to make sure it's finished, we should spawn a local loop and run it in there ... which is finicky. By the nature of unsubscribe
and subscribe
, we are not sure that we've got any state change, as the only thing those two functions do is send the message.
In order to properly handle this, these functions should've been async
in the first place, but that can only be changed in the V3.
Update documentation to reflect the automatic presence enablement behavior introduced in supabase-py PR #1229. Presence is now automatically enabled when presence callbacks are attached to a channel. Changes: - Updated subscribe() method notes in supabase_py_v2.yml - Added note about automatic presence enablement when callbacks are attached - Documented automatic resubscription behavior when callbacks are added post-join - Maintains existing documentation structure and formatting Source: supabase/supabase-py#1229 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
Summary
enabled
field toRealtimeChannelPresenceConfig
type definition_has_callback_attached
property toAsyncRealtimePresence
class to detect if any presence callbacks are registeredpresence.enabled=true
when presence callbacks are attached or manually configuredTest plan
_has_callback_attached
propertyenabled
fieldpresence.enabled
flag setting🤖 Generated with Claude Code